home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Tools / TASM V5 / TASMDOC.PAK / TLINK.TXT < prev    next >
Encoding:
Text File  |  1996-02-21  |  34.1 KB  |  908 lines

  1. /*************************************************************************/
  2.                                  TLINK.TXT
  3.                                TURBO ASSEMBLER
  4.  
  5. This file contains details on using TLINK with TASM.
  6.  
  7. --------------------------------------------------------------------
  8.                         TABLE OF CONTENTS
  9.                         - - - - - - - - -
  10.    TLINK basics
  11.       TLINK.CFG
  12.       Response files
  13.    TLINK options
  14.    Module-definition file reference
  15.       CODE statement
  16.       DATA statement
  17.       DESCRIPTION statement
  18.       EXETYPE statement
  19.       EXPORTS statement
  20.       IMPORTS statement
  21.       LIBRARY statement
  22.       NAME statement
  23.       SEGMENTS statement
  24.       STACKSIZE statement
  25.       STUB statement
  26.       Module-definition file defaults
  27.  
  28. --------------------------------------------------------------------
  29.  
  30. TLINK and TLINK32 are command-line tools that combine object modules
  31. (.OBJ files) and library modules (.LIB files) to produce executable
  32. files. The IDE uses built-in versions of the linkers. Because the
  33. compiler automatically calls the linker, you don't need to use TLINK
  34. unless you suppress the linking stage of compiling (see the -c
  35. compiler option). Unless otherwise specified, instructions and options
  36. for TLINK also apply to TLINK32.
  37.  
  38.  
  39. TLINK basics
  40. ============
  41. TLINK uses a configuration file called TLINK.CFG (TLINK32.CFG for
  42. TLINK32), a response file (optional), and command-line options to
  43. link object modules, libraries, and resources into an executable file
  44. (.EXE or .DLL). The IDE linker uses the options specified in the
  45. Project Options dialog box in the Linker section. The syntax for
  46. TLINK is:
  47.  
  48. TLINK [@respfile][options] startupfile myobjs, exename, [mapfile],
  49. [mylibs] runtimelib [import], [deffile], [resfiles]
  50.  
  51.  
  52.   o  'options' are TLINK options that control how TLINK works.
  53.      For example, options specify whether to produce an .EXE
  54.      or a DLL file. TLINK options must be preceded by either
  55.      a slash (/) or a hyphen (-). To turn off a default option,
  56.      place a hyphen after the option (for example, -P-).
  57.  
  58.   o  'startupfile' is a Borland initialization module for
  59.      executables or DLLs that arranges the order of the various
  60.      segments of the program. The initialization module must appear
  61.      first in the object file list. If it isn't first, the program
  62.      segments might not be placed in memory properly, which could
  63.      cause some frustrating program bugs. Failure to link the correct
  64.      initialization module usually results in a long list of error
  65.      messages telling you that certain identifiers are unresolved,
  66.      or that no stack has been created.
  67.  
  68.   o  'myobjs' are the .OBJ files you want linked. Specify the path
  69.      if the files aren't in the current directory.
  70.  
  71.   o  'exename' is the name you want given to the executable file
  72.      (.EXE or .DLL). If you don't specify an executable file name,
  73.      TLINK derives the name of the executable by appending .EXE or
  74.      .DLL to the first object file name listed. Be sure you give an
  75.      explicit name for the executable file name on the TLINK command
  76.      line. Otherwise, your program name will be something like
  77.      C02.EXE--which probably isn't what you wanted.
  78.  
  79.   o  'mapfile' (optional) is the name you want given to the map
  80.      file. If you don't specify a name, the map file name is
  81.      given the same as exefile (but with the .MAP extension).
  82.  
  83.   o  'mylibs' (optional) are the library files you want included at
  84.      link time. If these files aren't in the current directory or
  85.      the search path (see the /L option) then you must include their
  86.      paths.
  87.  
  88.   o  'runtimelib' is the Borland run-time library. If no libraries
  89.      are included, none are linked.
  90.  
  91.   o  'importlib' is the Windows import library, which provides
  92.      access to the Microsoft Windows API functions.
  93.  
  94.   o  'deffile' is the module-definition file (.DEF) for a Windows
  95.      executable. If you don't specify a .DEF file, TLINK creates
  96.      an application based on default settings.
  97.  
  98.   o  'resfiles' are a list of .RES files to bind to the executable.
  99.  
  100.  
  101. TLINK assumes or appends these extensions to file names that have
  102. none:
  103.  
  104.   o  .OBJ for object files
  105.  
  106.   o  .EXE for executable files
  107.  
  108.   o  .DLL for dynamic-link libraries
  109.  
  110.   o  .MAP for map files
  111.  
  112.   o  .LIB for library files
  113.  
  114.   o  .DEF for module-definition files
  115.  
  116.   o  .RES for resource files
  117.  
  118.  
  119. TLINK.CFG
  120. ---------
  121. TLINK uses a configuration file called TLINK.CFG (or TLINK32.CFG) for
  122. options that you'd normally type at the command-line (note that
  123. TLINK.CFG can only be options, not file names). Configuration files
  124. let you save options you use frequently, so that you don't have to
  125. continually retype them.
  126.  
  127. TLINK looks for TLINK.CFG in the current directory, then in the
  128. directory from which TLINK was loaded.
  129.  
  130. The following TLINK.CFG file tells TLINK to look for libraries first
  131. in the directory C:\BC4\LIB and then in C:\WINAPPS\LIB, to include
  132. debug information in the executables it creates, to create a detailed
  133. segment map, and to produce a Windows executable (.EXE not .DLL).
  134.  
  135.     TLINK                TLINK32
  136.     -----                -------
  137.     /Lc:\bc4\lib;c:\winapps\lib    /Lc:\bc4\lib;c:\winapps\lib
  138.     /v /s                /v /s
  139.     /Twe                /Tpe
  140.  
  141.  
  142. Response files
  143. --------------
  144. Response files are ASCII files of options and file names for TLINK.EXE
  145. (and TLINK32.EXE) that you would normally type at the command line.
  146. Response files let you have a longer command line than most operating
  147. systems allow. Response files can include the same information as
  148. configuration files (command-line options), but they can also contain
  149. file names.
  150.  
  151. Unlike the command line, a response file can be several lines long. To
  152. use more than one line in your response file, end each line with a
  153. plus character (+). Note that if a line ends with an option that uses
  154. the plus to turn it on (such as /v+), the + isn't treated as a line
  155. continuation character (to continue the line, use /v++).
  156.  
  157. If you separate command-line components (such as .OBJ files from .LIB
  158. files) by lines in a response file, you must leave out the comma used
  159. to separate them on the command line. For example:
  160.  
  161.     /c c0ws+
  162.        myprog,myexe
  163.        mymap
  164.        mylib cws
  165.  
  166. leaves out the commas you'd have to type if you put the information on
  167. the command line:
  168.  
  169.     TLINK /c c0ws myprog, myexe, mymap, mylib cws
  170.  
  171. To use response files:
  172.  
  173.  1) Type the command-line options and file names into an ASCII text
  174.     file and save the file.
  175.  
  176.  2) Type TLINK @[path]RESFILE.RSP, where RESFILE.RSP is the name
  177.     of your response file.
  178.  
  179. You can specify more than one response file as follows:
  180.  
  181.     TLINK /c @listobjs, myexe, mymap, @listlibs
  182.  
  183. If you use a response file in addition to command-line options, the
  184. command-line options will override any options in the response file.
  185. For example, if you include -v in a response file, but you use -v- at
  186. the command-line, TLINK uses the command-line option -v-.
  187.  
  188.  
  189. TLINK options
  190. =============
  191. Unless otherwise specified, options work with both TLINK and TLINK32.
  192. Options are case-sensitive and must be preceded by either a slash (/)
  193. or a hyphen (-). To turn off a default option, place a hyphen after
  194. the option at the command-line (for example, -P- or /P-). You can
  195. place options anywhere in the command line. You don't need spaces
  196. after options (/m/f/c is the same as /m  /f  /c), but you must
  197. separate options and files with a space.
  198.  
  199. The following table lists the TLINK options. A more detailed
  200. explanation of options follows the table.
  201.  
  202. Option    For        Description
  203. ------    ---        -----------
  204. /3    16-bit        Accepts and links 32-bit code produced by TASM
  205.             or a compatible assembler.
  206.  
  207. /ax    32-bit        Specifies application type, where
  208.             /aa targets Windows applications
  209.             /ap targets console applications.
  210.  
  211. /A:dd    16/32-bit    Specifies page alignment within .EXE file.
  212.  
  213. /B:xxx    32-bit    Specifies image base address (in hexadecimal).
  214.  
  215. /c    16/32-bit    Treats case as significant in symbols.
  216.  
  217. /C    16-bit        Treats case as significant in EXPORTS and
  218.             IMPORTS section of module-definition file.
  219.  
  220. /d    16-bit        Warns you if there are duplicate symbols in
  221.             libraries.
  222.  
  223. /E    16-bit        Enables processing of extended dictionaries in
  224.             libraries.
  225.  
  226. /Enn    32-bit        Specifies maximum errors before termination.
  227.  
  228. /e    16-bit        Ignores extended dictionaries in libraries.
  229.             This is the opposite of the /E option.
  230.  
  231. /f    16-bit        Inhibits optimization of far calls to near
  232.             data.
  233.  
  234. /Gn    16-bit        Discard nonresident name table.
  235.  
  236. /Gr    16-bit        Transfer Resident names to nonresident names
  237.             table.
  238.  
  239. /Gm    16/32-bit    Put Mangled names in map file.
  240.  
  241. /i    16-bit        Initializes all segments.
  242.  
  243. /l    16-bit        Includes source line numbers (lowercase L).
  244.  
  245. /L    16/32-bit    Specifies library search paths.
  246.  
  247. /m    16/32-bit    Creates map file with publics.
  248.  
  249. /n    16-bit        Don't use default libraries.
  250.  
  251. /o    16-bit        Overlays modules or libraries.
  252.  
  253. /P    16-bit        Packs code segments.
  254.  
  255. /R    16-bit        Sends options to RLINK.EXE. Possible
  256.             options are /Re, /Rk, /Rl, /m, /Rp, and /Rv.
  257.  
  258. /Rexxx    32-bit        Renames the executable to xxx.
  259.  
  260. /S:xxx    32-bit        Specifies stack size (in hexadecimal).
  261.  
  262. /s    16-bit        Creates detailed map of segments.
  263.  
  264. /t    16-bit        Creates a tiny-model DOS .COM file.
  265.  
  266. /Tdx    16-bit        Specifies application target, where
  267.             /Tde means build a DOS .EXE file.
  268.  
  269. /Tpx    32-bit        Specifies application target, where
  270.             /Tpe means build a 32-bit .EXE file.
  271.             /Tpd means build a 32-bit DLL.
  272.  
  273. /Twx    16-bit        Specifies Windows 3.x target application,
  274.             where
  275.             /Twe builds a Windows .EXE file.
  276.             /Twd builds a Windows DLL.
  277.  
  278. /v    16/32-bit    Includes full symbolic debug information.
  279.  
  280. /wxxx    32-bit        Enable or disable warnings.
  281.  
  282. /x    16/32-bit    Doesn't create a map file.
  283.  
  284. /ye    16-bit        Uses expanded memory for swapping.
  285.  
  286. /yx    16-bit        Configures TLINK's use of extended memory
  287.             swapping.
  288.  
  289.  
  290. /3 (32-bit code) lets you link 32-bit DOS object modules produced by
  291. TASM or a compatible assembler. This option increases the memory
  292. requirements for TLINK and slows down linking.
  293.  
  294. /a (application type) lets you specify the type of EXE image:
  295.  
  296.   o  /aa targets Windows applications.
  297.  
  298.   o  /ap targets console applications that can be run in a window.
  299.  
  300. /A:dd (align pages) specifies page alignment for code and data within
  301. the executable file where dd must be a decimal power of 2. For
  302. example, if you specify an alignment value of /A:12, the sections in
  303. the image are stored on 4096-byte boundaries. The operating system
  304. seeks pages for loading based on this alignment value. The default is
  305. /A:9, which means sections are aligned on 512-byte boundaries within
  306. the executable file.
  307.  
  308. /B:xxxxxx (base address) specifies an image base address for an
  309. application. If this option is used, internal fixups are removed from
  310. the image, and the requested load address of the first object is set
  311. to the hexadecimal number given with the option. All successive
  312. objects are aligned on 64K linear address boundaries. This option
  313. makes applications smaller on disk, and improves both load-time and
  314. run-time performance since the operating system no longer has to apply
  315. internal fixups. Because NT loads all .EXE images at 64K, you're
  316. advised to link all .EXEs with /B:0x10000.
  317.  
  318. /c (case sensitivity) makes the case significant in public and
  319. external symbols.
  320.  
  321. /C (case sensitivity) makes the case significant in the EXPORTS and
  322. IMPORTS sections in module-definition files.
  323.  
  324. /d (duplicate symbols) warns you if a symbol appears in more than one
  325. library file. If the symbol must be included in the program, TLINK
  326. uses the symbol from the first file containing the symbol that is
  327. specified on the command line (or in a response file). This option
  328. also warns you if symbols appear in both an .OBJ file and a .LIB file
  329. (TLINK uses the first one linked in and ignores the others).
  330.  
  331. /Enn (maximum errors) specifies the maximum number of errors the
  332. linker reports before terminating. /E0 (the default) reports an
  333. infinite number of errors (that is, as many as possible).
  334.  
  335. /E (extended dictionaries) processes extended dictionaries. The
  336. library files in Borland C++ contain an extended dictionary with
  337. information that lets TLINK use less memory and link faster with those
  338. libraries. You can add the extended dictionary to other library files
  339. using TLIB's /E option. Avoid using /E with programs linked with
  340. libraries that have been built without an extended dictionary
  341. (third-party libraries that have been provided without source code,
  342. for example). To use extended dictionaries, all linked libraries must
  343. have extended dictionaries.
  344.  
  345. /e (ignore extended dictionaries) ignores extended dictionaries. This
  346. is the opposite of the /E option, and is the default.
  347.  
  348. /f (inhibit far optimizations) inhibits the optimization of far calls
  349. to near data.
  350.  
  351. /Gx (Goodies) are options where x can be
  352.     n = Discard nonresident name table. (16-bit only)
  353.     r = Transfer resident names to nonresident table. (16-bit only)
  354.     m = (TLINK32) Put mangled names in map file; this can help you
  355.         identify how names are mangled.
  356.  
  357. /i (uninitialized trailing segments) outputs uninitialized trailing
  358. segments into the executable file even if the segments don't contain
  359. data records.
  360.  
  361. /l (line numbers) creates a section in the .MAP file for source-code
  362. line numbers. Linked .OBJ files must be compiled with debug
  363. information using -y or -v. If you use /x to suppress map file
  364. creation, the /l (lowercase L) option has no effect.
  365.  
  366. /L (library search paths) lets you list directories for TLINK to
  367. search if you don't type an explicit path for a library or the C or
  368. C++ initialization module. TLINK searches the current directory first
  369. (where you typed TLINK). For example:
  370.  
  371.     TLINK /Lc:\BC4\lib;c:\mylibs splash logo,,,utils .\logolib
  372.  
  373. first searches the current directory for UTILS.LIB, then searches
  374. C:\BC4\LIB, then C:\MYLIBS. Because @WORD(LOGOLIB) explicitly names
  375. the current directory, TLINK doesn't search the libraries specified
  376. with the /L option to find LOGOLIB.LIB.
  377.  
  378. /m (detailed map file) creates a more complete map than TLINK normally
  379. does by adding a list of sorted public symbols to the map file. This
  380. kind of map file is useful in debugging. Many debuggers can use the
  381. list of public symbols, which lets you refer to symbolic addresses
  382. when you're debugging. If you don't specify map file options (/m, /s,
  383. or /x), then the option Map File|Segments is used. See also /s.
  384.  
  385. /M (map mangled) maps with mangled public names.
  386.  
  387. /n (ignore default libraries) ignores default libraries specified by
  388. some compilers. Use this option when linking modules that are written
  389. in another language.
  390.  
  391. /o (overlays) overlays code in all the modules or libraries that
  392. follow the option on the command line (this option works for DOS
  393. applications only). Use /o- on the command line to turn off overlays.
  394. If you specify a class name after this option, all the segments in
  395. that class are overlaid (you can do this for multiple classes). If you
  396. don't specify any name after this option, all segments of classes
  397. ending with CODE are overlaid. This option uses the default overlay
  398. interrupt number of 3FH. To specify a different interrupt number, use
  399. /o#xx, where xx is a two-digit hexadecimal number.
  400.  
  401. /P (pack code segments) combines as many code segments as possible in
  402. one physical segment up to (and never greater than) the code-segment
  403. packing limit. TLINK starts a new segment if it needs to. The default
  404. code-segment packing limit is 8,192 bytes (8K). To change it, use /P=n
  405. where n specifies the number of bytes between 1 and 65,536. You would
  406. probably want the limit to be a multiple of 4K under 386 enhanced mode
  407. because of the paging granularity of the system.
  408.  
  409. Although the optimum segment size in 386 enhanced mode is 4K, the
  410. default code-segment packing size is 8K because typical code segments
  411. are from 4K to 8K and 8K might pack more efficiently.
  412.  
  413. Because each maintained segment has some system overhead, code-segment
  414. packing typically increases performance. /P- turns off code-segment
  415. packing (useful if you've turned it on in the configuration file and
  416. want to disable it for a particular link).
  417.  
  418. /s (detailed segment map) creates a map file with the same features as
  419. the /m option, but adds a detailed segment map. If you don't specify
  420. map file options (/m, /s, or /x), then the option Map File|Segments is
  421. used. For each segment in each module, this map file includes the
  422. address, length in bytes, class, segment name, group, module, and ACBP
  423. information. If the same segment appears in more than one module, each
  424. module appears as a separate line. Except for the ACBP field, the
  425. information in the detailed segment map is self-explanatory.
  426.  
  427. The ACBP field encodes the A (alignment), C (combination), and B (big)
  428. attributes into a set of four bit fields, as defined by Intel. TLINK
  429. uses only three of the fields, the A, C, and B fields. The ACBP value
  430. in the map is printed in hexadecimal. The following values of the
  431. fields must be OR'ed together to arrive at the ACBP value printed.
  432.  
  433. Field                Value    Description
  434. -----                -----    -----------
  435. The A field (alignment)        00    An absolute segment.
  436.                 20    A byte-aligned segment.
  437.                 40    A word-aligned segment.
  438.                 60    A paragraph-aligned segment.
  439.                 80    A page-aligned segment.
  440.                 A0    An unnamed absolute portion of
  441.                     storage.
  442.  
  443. The B field (big)        00    Segment less than 64K.
  444.                 02    Segment exactly 64K.
  445.  
  446. The C field (combination)    00    Cannot be combined.
  447.                 08    A public combining segment.
  448.  
  449. With the /s option, public symbols with no references are flagged
  450. "idle." An idle symbol is a publicly-defined symbol in a module that
  451. wasn't referenced by an EXTDEF record by any other module included in
  452. the link. For example, this fragment from the public symbol section of
  453. a map file indicates that symbols Symbol1 and Symbol3 aren't
  454. referenced by the image being linked:
  455.  
  456.     0002:00000874    Idle    Symbol1
  457.     0002:00000CE4        Symbol2
  458.     0002:000000E7    Idle    Symbol3
  459.  
  460. /S:xxxxxx (stack size) sets the application stack size in hexadecimal
  461. where xxxxxx is a hexadecimal string. Specifying the stack size with
  462. /S overrides any stack size setting in a module-definition file.
  463.  
  464. /Tdx (DOS target) produces a DOS .EXE (/Tde) file.
  465.  
  466. /Tpx (protected target) produces a protected mode .EXE (/Tpe) or .DLL
  467. file (/Tpd).
  468.  
  469. /Twx (target type) produces a Windows .EXE (/Twe) or .DLL file (/Twd).
  470. This option isn't necessary if you include a module-definition file
  471. with an EXETYPE Windows statement because TLINK creates an application
  472. (.EXE) if the module-definition file has a NAME statement or a DLL if
  473. the module-definition file has a LIBRARY statement.
  474.  
  475. /v (debugging information) includes debugging information in the
  476. executable file. If this option is found anywhere on the command line,
  477. debugging information is included in the executable file for all
  478. object modules that contain debugging information. You can use the /v+
  479. and /v- options to selectively enable or disable debugging information
  480. on a module-by-module basis (but not on the same command line as /v).
  481. For example, the command
  482.  
  483.     TLINK mod1 /v+ mod2 mod3 /v- mod4
  484.  
  485. includes debugging information for modules mod2 and mod3, but not for
  486. mod1 and mod4.
  487.  
  488. /wxxx (warning control) turns on (/wxxx) or off (/w-xxx) TLINK
  489. warnings, where xxx can be one of the following (defaults mean TLINK
  490. will send the warning without you specifically turning it on):
  491.  
  492. Option        Description
  493. ------        -----------
  494. bdl        Using based linking in DLLs (might cause the DLL to
  495.         malfunction)
  496.  
  497. def        No .DEF file; using defaults
  498.  
  499. dpl        Warn duplicate symbol in .LIB
  500.  
  501. dup        Duplicate symbol (warning for .OBJs)
  502.  
  503. ent        No entry point
  504.  
  505. imt        Import doesn't match previous definition
  506.  
  507. srf        Self-relative fixup overflowed
  508.  
  509.  
  510. /x (no map file) tells TLINK to not generate a map file. TLINK usually
  511. creates map files that list segments in the program, the program start
  512. address, and any TLINK warning or error messages (the Map
  513. File|Segments option, which has no command-line option, is on by
  514. default).
  515.  
  516. /ye (expanded memory) controls TLINK's use of expanded memory for I/O
  517. buffering. If TLINK needs more memory for active data structures
  518. (while reading object files or writing the executable file), it either
  519. clears buffers or swaps them to expanded memory.
  520.  
  521. When reading files, TLINK clears the input buffer so that its space
  522. can be used for other data structures. When creating an executable, it
  523. writes the buffer to its correct place in the executable file. In both
  524. cases, you can substantially increase the link speed by swapping to
  525. expanded memory. By default, swapping to expanded memory is enabled,
  526. and swapping to extended memory is disabled. If swapping is enabled
  527. and no appropriate memory exists in which to swap, then swapping
  528. doesn't occur.
  529.  
  530. This option has several forms, shown below:
  531.  
  532.   o  /ye or /ye+ enables expanded memory swapping (this is the
  533.      default).
  534.  
  535.   o  ye- disables expanded memory swapping (this is off by default).
  536.  
  537. /yx (extended memory) controls TLINK's use of extended memory for I/O
  538. buffering. By default, TLINK can use up to 8MB of extended memory. You
  539. can change TLINK's use of extended memory with one of the following
  540. forms of this option:
  541.  
  542.   o  /yx+ uses all available extended memory up to 8MB.
  543.  
  544.   o  /yxn uses only up to n KB extended memory.
  545.  
  546.  
  547. Module-definition file reference
  548. ================================
  549. This section describes module-definition files and the statements that
  550. appear in them. A module-definition file provides information to TLINK
  551. about the contents and system requirements of a Windows application.
  552. More specifically, a module-definition file does the following:
  553.  
  554.   o  Names the .EXE or .DLL.
  555.  
  556.   o  Identifies the application type.
  557.  
  558.   o  Lists imported and exported functions.
  559.  
  560.   o  Describes the code and data segment attributes, and lets you
  561.      specify attributes for additional code and data segments.
  562.  
  563.   o  Specifies the size of the stack.
  564.  
  565.   o  Provides for the inclusion of a stub program.
  566.  
  567.  
  568. CODE statement
  569. --------------
  570. CODE defines the default attributes of code segments. Code segments
  571. can have any name, but must belong to segment classes whose name ends
  572. in CODE (such as CODE or MYCODE). The syntax is:
  573.  
  574.        TLINK            TLINK32
  575. CODE [FIXED|MOVEABLE]        [PRELOAD|LOADONCALL]
  576.      [DISCARDABLE|NONDISCARDABLE]    [EXECUTEONLY|EXECUTEREAD]
  577.      [PRELOAD|LOADONCALL]
  578.  
  579.   o  'FIXED' (the default) means the segment remains at a fixed
  580.      memory location; 'MOVEABLE' means the segment can be moved.
  581.  
  582.   o  'PRELOAD' means code is loaded when the calling program is
  583.      loaded. 'LOADONCALL' (the default) means the code is loaded
  584.      when called by the program.
  585.  
  586.   o  'DISCARDABLE' means the segment can be discarded if it is no
  587.      longer needed (this implies MOVABLE). 'NONDISCARDABLE' (the
  588.      default) means the segment can't be discarded.
  589.  
  590.   o  'EXECUTEONLY' means a code segment can only be executed.
  591.      'EXECUTEREAD' (the default) means the code segment can be
  592.      read and executed.
  593.  
  594.   o  'PRELOAD' means the segment is loaded when the module is first
  595.      loaded. 'LOADONCALL' (the default) means the segment is loaded
  596.       when called.
  597.  
  598.  
  599. DATA statement
  600. --------------
  601. DATA defines attributes of data segments. The syntax is:
  602.  
  603.     DATA [NONE | SINGLE | MULTIPLE]
  604.          [READONLY | READWRITE]
  605.          [PRELOAD | LOADONCALL]
  606.          [SHARED | NONSHARED]
  607.  
  608.   o  'NONE' means that there is no data segment created. This
  609.      option is available only for libraries. 'SINGLE' (the
  610.      default for .DLLs) means a single data segment is created
  611.      and shared by all processes. 'MULTIPLE' (the default for .EXEs)
  612.      means a data segment is created for each process.
  613.  
  614.   o  'READONLY' means the data segment can be read only. 'READWRITE'
  615.      (the default) means the data segment can be read and written to.
  616.  
  617.   o  'PRELOAD' means the data segment is loaded when a module that
  618.      uses it is first loaded. 'LOADONCALL' (the default) means the
  619.      data segment is loaded when it is first accessed (this is
  620.      ignored for 32-bit applications).
  621.  
  622.   o  'SHARED' (the default for 16-bit .DLLs) means one copy of the
  623.      data segment is shared among all processes. 'NONSHARED' (the
  624.      default for programs and 32-bit .DLLs) means a copy of the
  625.      data segment is loaded for each process needing to use the
  626.      data segment.
  627.  
  628.  
  629. DESCRIPTION statement
  630. ---------------------
  631. DESCRIPTION (optional) inserts text into the application module and is
  632. typically used to embed author, date, or copyright information. The
  633. syntax is:
  634.  
  635.     DESCRIPTION 'Text'
  636.  
  637. 'Text' is an ASCII string delimited with single quotes.
  638.  
  639.  
  640. EXETYPE statement
  641. -----------------
  642. EXETYPE defines the default executable file (.EXE) header type for
  643. 16-bit application. You can leave this section in for 32-bit
  644. application for backward compatibility, but if you need to change the
  645. EXETYPE, refer to the NAME statement. The syntax for EXETYPE is:
  646.  
  647.     EXETYPE  WINDOWS
  648.  
  649.  
  650. EXPORTS statement
  651. -----------------
  652. EXPORTS defines the names and attributes of functions to be exported.
  653. The EXPORTS keyword marks the beginning of the definitions. It can be
  654. followed by any number of export definitions, each on a separate line.
  655. The syntax is:
  656.  
  657.     EXPORTS ExportName [Ordinal] [RESIDENTNAME] [Parameter]
  658.  
  659.   o  'ExportName' specifies an ASCII string that defines the
  660.      symbol to be exported:
  661.  
  662.     EntryName [=InternalName]
  663.  
  664.     'InternalName' is the name used within the application to
  665.     refer to this entry. 'EntryName' is the name listed in the
  666.     executable file's entry table and is externally visible.
  667.  
  668.   o  'Ordinal' defines the function's ordinal value as follows:
  669.  
  670.     @ordinal
  671.  
  672.     where 'ordinal' is an integer value that specifies the
  673.     function's ordinal value.
  674.  
  675.     When an application or DLL module calls a function exported
  676.     from a DLL, the calling module can refer to the function by
  677.     name or by ordinal value. It's faster to refer to the function
  678.     by ordinal because string comparisons aren't required to
  679.     locate the function. To use less memory, export a function by
  680.     ordinal (from the point of view of that function's DLL) and
  681.     import/call a function by ordinal (from the point of view of
  682.     the calling module).
  683.  
  684.     When a function is exported by ordinal, the name resides in
  685.     the nonresident name table. When a function is exported by
  686.     name, the name resides in the resident name table. The
  687.     resident name table for a module is in memory whenever the
  688.     module is loaded; the nonresident name table isn't.
  689.  
  690.   o  'RESIDENTNAME' specifies that the function's name must be
  691.      resident at all times. This is useful only when exporting
  692.      by ordinal (when the name wouldn't be resident by default).
  693.  
  694.   o  'Parameter' is an optional integer value that specifies the
  695.      number of words the function expects to be passed as parameters.
  696.  
  697.  
  698. IMPORTS statement
  699. -----------------
  700. IMPORTS defines the names and attributes of functions to be imported
  701. from DLLs. Instead of listing imported DLL functions in the IMPORTS
  702. statement, you can do the following:
  703.  
  704.   o  Specify an import library for the DLL in the TLINK command
  705.      line, or
  706.  
  707.   o  Include the import library for the DLL in the project manager
  708.      in the IDE.
  709.  
  710. If you're programming for 32-bits, you must write your own indirection
  711. to import any function, class, or data you want imported. The following
  712. is an example of importing data with TASM32:
  713.  
  714.     _TEXT        segment dword public 'CODE'
  715.  
  716.     extrn        _foo:dword    ;This is an imported integer
  717.  
  718.     _bar        PROC
  719.  
  720.         mov    eax, -foo
  721.         mov    eax, [eax]
  722.         ret
  723.  
  724.     _bar        ENDP
  725.  
  726.     _TEXT        ends
  727.     end
  728.  
  729.  
  730. The IMPORTS keyword marks the beginning of the definitions; it is
  731. followed by any number of import definitions, each on a separate line.
  732. The syntax is:
  733.  
  734.     IMPORTS  [InternalName=]ModuleName.Entry
  735.  
  736.   o  'InternalName' is an ASCII string that specifies the unique
  737.      name the application uses to call the function.
  738.  
  739.   o  'ModuleName' specifies one or more uppercase ASCII characters
  740.      that define the name of the executable module containing the
  741.      function. The module name must match the name of the
  742.      executable file. For example, the file SAMPLE.DLL has the
  743.      module name SAMPLE.
  744.  
  745.   o  'Entry' specifies the function to be imported--either an ASCII
  746.      string that names the function or an integer that gives the
  747.      function's ordinal value.
  748.  
  749.  
  750. LIBRARY statement
  751. -----------------
  752. LIBRARY defines the name of a DLL module. A module-definition file can
  753. contain either a LIBRARY statement to indicate a DLL or a NAME
  754. statement to indicate a program.
  755.  
  756. A library's module name must match the name of the executable file.
  757. For example, the library MYLIB.DLL has the module name MYLIB. The
  758. syntax is:
  759.  
  760.     LIBRARY LibraryName [INITGLOBAL | INITINSTANCE]
  761.  
  762.   o  'LibraryName' (optional) is an ASCII string that defines
  763.      the name of the library module. If you don't include a
  764.      LibraryName, TLINK uses the file name with the extension
  765.      removed. If the module-definition file includes neither a
  766.      NAME nor a LIBRARY statement, TLINK assumes a NAME statement
  767.      without a ModuleName parameter.
  768.  
  769.   o  'INITGLOBAL' means the library-initialization routine is called
  770.      only when the library module is first loaded into memory.
  771.      'INITINSTANCE' means the library-initialization routine is called
  772.      each time a new process uses the library.
  773.  
  774.  
  775. NAME statement
  776. --------------
  777. NAME is the name of the application's executable module. The module
  778. name identifies the module when exporting functions. For 32-bit
  779. applications, NAME must appear before EXETYPE. If NAME and EXETYPE
  780. don't specify the same target type, the type listed with NAME is used.
  781. The syntax is:
  782.  
  783.     NAME  ModuleName [WINDOWSAPI] | [WINDOWCOMPAT]
  784.  
  785.   o  'ModuleName' (optional) specifies one or more uppercase ASCII
  786.      characters that name the executable module. The name must
  787.      match the name of the executable file. For example, an
  788.      application with the executable file SAMPLE.EXE has the module
  789.      name SAMPLE.
  790.  
  791.      If ModuleName is missing, TLINK assumes the module name matches
  792.      the file name of the executable file. For example, if you don't
  793.      specify a module name and the executable file is named MYAPP.EXE,
  794.      TLINK assumes the module name is MYAPP.
  795.  
  796.      If the module-definition file includes neither a NAME nor a
  797.      LIBRARY statement, TLINK assumes a NAME statement without a
  798.      ModuleName parameter.
  799.  
  800.   o  'WINDOWAPI' is a Windows executable, and is equivalent to the
  801.      TLINK32 option /aa.
  802.  
  803.   o  'WINDOWCOMPAT' is a Windows-compatible character-mode executable,
  804.      and is equivalent to the TLINK32 option /ap.
  805.  
  806.  
  807. SEGMENTS statement
  808. ------------------
  809. SEGMENTS defines the segment attributes of additional code and data
  810. segments. The syntax is:
  811.  
  812.     SEGMENTS
  813.         SegmentName [CLASS 'ClassName'] [MinAlloc]
  814.         [SHARED | NONSHARED]
  815.         [PRELOAD | LOADONCALL]
  816.  
  817.   o  'SegmentName' is a character string that names the new segment.
  818.      It can be any name, including the standard segment names _TEXT
  819.      and _DATA, which represent the standard code and data segments.
  820.  
  821.   o  'ClassName' (optional) is the class name of the specified
  822.      segment. If no class name is specified, TLINK uses the
  823.      class name CODE.
  824.  
  825.   o  'MinAlloc' (optional) is an integer that specifies the minimum
  826.      allocation size for the segment. TLINK and TLINK32 ignore this
  827.      value.
  828.  
  829.   o  'SHARED' (the default for 16-bit .DLLs) means one copy of the
  830.      segment is shared among all processes. 'NONSHARED' (the default
  831.      for programs and 32-bit .DLLs) means a copy of the segment is
  832.      loaded for each process needing to use the data segment.
  833.  
  834.   o  'PRELOAD' means that the segment is loaded immediately;
  835.      'LOADONCALL' means that the segment is loaded when it is
  836.      accessed or called (this is ignored by TLINK32). The resource
  837.      compiler might override the LOADONCALL option and preload
  838.      segments instead.
  839.  
  840.  
  841. STACKSIZE statement
  842. -------------------
  843. STACKSIZE defines the number of bytes needed by the application for
  844. its local stack. An application uses the local stack whenever it makes
  845. function calls. Don't use the STACKSIZE statement for dynamic-link
  846. libraries. The syntax is:
  847.  
  848.     STACKSIZE bytes
  849.  
  850. bytes is an integer value that specifies the stack size in bytes.
  851.  
  852.  
  853. STUB statement
  854. --------------
  855. STUB appends a DOS executable file specified by FileName to the
  856. beginning of the module. The executable stub displays a warning
  857. message and terminates if the user attempts to run the executable stub
  858. in the wrong environment (running a Windows application under DOS, for
  859. example).
  860.  
  861. Borland C++ adds a built-in stub to the beginning of a Windows
  862. application unless a different stub is specified with the STUB
  863. statement. You shouldn't use the STUB statement to include WINSTUB.EXE
  864. because the linker does this automatically. The syntax is:
  865.  
  866.     STUB 'FileName'
  867.  
  868. 'FileName' is the name of the DOS executable file to be appended to
  869. the module. The name must have the DOS file name format.
  870.  
  871. If the file named by FileName isn't in the current directory, TLINK
  872. searches for the file in the directories specified by the PATH
  873. environment variable.
  874.  
  875.  
  876. Module-definition file defaults
  877. -------------------------------
  878. The module-definition file isn't strictly necessary to produce a
  879. Windows executable under borland C++.
  880.  
  881. If no module-definition file is specified, the following defaults are
  882. assumed:
  883.  
  884.     CODE        PRELOAD MOVEABLE DISCARDABLE
  885.     DATA        PRELOAD MOVEABLE MULTIPLE (for applications)
  886.             PRELOAD MOVEABLE SINGLE (for DLLs)
  887.             HEAPSIZE    4096
  888.             STACKSIZE        5120 (1048576 for TLINK32)
  889.  
  890. To replace the EXETYPE statement, the Borland C++ linker can discover
  891. what kind of executable you want to produce by checking settings in
  892. the IDE or options on the command line.
  893.  
  894. You can include an import library to substitute for the IMPORTS
  895. section of the module definition file.
  896.  
  897. If you're coding in C or C++, you can use the _export keyword in the
  898. definitions of export functions to remove the need for an EXPORTS
  899. section. Note, however, that if _export is used to export a function,
  900. that function is exported by name rather than by ordinal (ordinal is
  901. usually more efficient).
  902.  
  903. If you want to change various attributes from the default, you'll need
  904. to have a module-definition file.
  905.  
  906. /**************************** END OF FILE ********************************/
  907.  
  908.